<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .my-link {
            color: #ccc;
        }

        .router-link-active {
            color: #000;
        }
    </style>
</head>

<body>
    <div id="app">
        <router-link class="my-link" :to="{'name':'user'}">用户</router-link>
        <router-link class="my-link" :to="{'name':'art'}">文章</router-link>
        <router-view></router-view>
    </div>
</body>
<script src="js/vue.js"></script>
<script src="js/vue-router.js"></script>
<script>
    // 1.声明路由
    let r1 = new VueRouter({
        routes: [{
            // 顶级路由地址加/
            path:'/user',
            name:'user',
            component: {
                template: '<div>用户</div>',
            }
        },{
            // 顶级路由地址加/
            path:'/art',
            name:'art',
            component: {
                template: '<div>用户</div>',
            }
        }]
    });
    // 2.调用路由

    let vm = new Vue({
        el: '#app',
        methods: {

        },
        router: r1,

    })
</script>

</html>